import numpy as np

data = []
while True:
    try:
        a = input().strip()
        data.append(a)
    except EOFError:
        break
# print(data)

array = []
for i in data:
    if i.startswith('\\') is True:
        continue
    array.append(i.split('\\')[0].split('&'))

h, w = len(array), len(array[0])
# print(h, w)
for i in range(w):
    for j in range(h):
        if j+1 == h:
            print(array[j][i], end='\\\\')
        else:
            print(array[j][i], end=' & ')
    print()
    if i == 0:
        print('\midrule')
    if i == w-2:
        print('\cmidrule{1-7}')

